<?php
/* 遍历数组 */
$cars=array("Volvo","BMW","Toyota");
$arrlength=count($cars);

for($x=0;$x<$arrlength;$x++)
{
    echo $cars[$x];
    echo "<br>";
}

/* PHP 关联数组:
 * 关联数组是使用您分配给数组的指定的键的数组。
 *
 * 这里有两种创建关联数组的方法：
 * $age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
 *
 * or:
 *
 * $age['Peter']="35";
 * $age['Ben']="37";
 * $age['Joe']="43";  */

$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
echo "Peter is " . $age['Peter'] . " years old.";
echo "<br>";

/* 遍历关联数组 */
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");

foreach($age as $x=>$x_value)
{
    echo "Key=" . $x . ", Value=" . $x_value;
    echo "<br>";
}
?> 
